<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="dfn" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="dtt" uri="http://www.appx.top/dateTimeTag" %>
<c:set var="page" value="${articleQO.page}"></c:set>
<c:set var="pageSize" value="${articleQO.pageSize}"></c:set>
<c:set var="title" value="${articleQO.title}"></c:set>
<!DOCTYPE html>
<html>
<head>
    <%@include file="inc/_header.jsp"%>
</head>
<body>
<header>
    <c:set var="nav_article" value="true"></c:set>
    <%@include file="inc/_nav.jsp" %>
</header>

<div class="container">
    <ol class="breadcrumb">
        <li>当前位置:</li>
        <c:choose>
            <c:when test="${folder==null}">
                <li class="active">所有板块</li>
            </c:when>
            <c:otherwise>
                <li class="active">${folder.rname}</li>
            </c:otherwise>
        </c:choose>
    </ol>

    <form action="/article/list.do" class="form-search">
        <div class="input-group col-md-3 pull-right">
			<span class="input-group-btn">
				<button title="点击切换分组" type="button" class="btn btn-default  dropdown-toggle" data-toggle="dropdown">
                    <span class="caret"></span>
                </button>

                    <ul class="dropdown-menu">
                        <li class="${folder==null?'active':''}">
                            <a href="/article/list.do?page=${page}&pageSize=${pageSize}">所有板块</a>
                        </li>
                    <c:forEach items="${folderList}" var="f">
                        <li class="${f.id==folder.id?'active':''}">
                            <a href="/article/list.do?page=${page}&pageSize=${pageSize}&fid=${f.id}">${f.rname}</a>
                        </li>
                    </c:forEach>
                </ul>
			</span>

            <input type="hidden" name="pageSize" value="${pageSize }" />
            <input type="hidden" name="fid" value="${fid }" />
            <input type="hidden" name="g" value="${g }" />
            <input class="form-control" type="search" name="title" id="searchbox" placeholder="在☆${folder.rname==null?'所有版块':folder.rname }☆下搜索" value="${title}" />
			<span class="input-group-btn">
				<button class="btn btn-default">
                    <i title="搜索" class="glyphicon glyphicon-search"></i>
                </button>
			</span>
        </div>
    </form>

    <div class="page-header">
        <c:choose>
            <c:when test="${session.user!=null}">
                <a target="_blank" class="btn btn-primary" href="/article_add.do?m=${m }">发帖</a>
            </c:when>
            <c:otherwise>
                <a title="请先登录" class="btn btn-primary" data-toggle="tooltip" href="/article_add.do?m=${m }">发帖</a>
            </c:otherwise>
        </c:choose>

        <c:choose>
            <c:when test="${g}">
                <a class="btn btn-primary" href="Article_list?m=${m }&sw=${sw}">所有帖子</a>
            </c:when>
       <%--     <c:otherwise>
                <a class="btn btn-primary" href="Article_list?m=${m }&sw=${sw}&g=true">精华帖</a>
            </c:otherwise>--%>

        </c:choose>
    </div>

    <c:choose>
        <c:when test="${fn:length(articleVOPager.rows)==0}">
            <div class="panel-body text-center">
                <h3>没有找到</h3>
            </div>
        </c:when>
        <c:otherwise>
            <ul class="list-group">
                <c:forEach items="${articleVOPager.rows}" var="article">
                    <li class="list-group-item">
                        <a target="_blank" href="/article/${article.id }.do">
                                ${article.title}
                        </a>
                            ${good?'<span class=\"label label-success\">精</span>':'' }
                        <span style="font-size: x-small;color: gray;">
                            <dtt:dateTimeTag time="${article.createTime}"/>
                        </span>

                    </li>
                </c:forEach>
            </ul>
        </c:otherwise>
    </c:choose>
</div>
<c:set var="page" value="${page==null?1:page}"></c:set>
<c:set var="pageSize" value="${pageSize==null?20:pageSize}"></c:set>
<c:set var="total" value="${articleVOPager.total}"></c:set>
<dfn:formatNumber var="maxPage" type="number" value="${total%pageSize==0?total/pageSize:(total/pageSize+1)}" maxFractionDigits="0"></dfn:formatNumber>
<c:set var="urlL" value="list.do?"></c:set>
<c:set var="bz" value="${12}"></c:set>
<c:if test="${maxPage>1}">
    ；；；--${maxPage}
<div class="text-center">
    <ul class="pagination">
        <li class="${page<=1?'disabled':'' }"><a href="${urlL }&page=1&pageSize=${pageSize}">&laquo;</a></li>
        <li class="${page<=1?'disabled':'' }"><a href="${urlL }&page=${page-1 }&pageSize=${pageSize}">上一页</a></li>
        <c:if test="${bz==null}">
            <c:set var="bz" value="${10}"></c:set>
        </c:if>
        <c:choose>
            <c:when test="${maxPage<=bz}">
                <c:set var="beginPage" value="1"></c:set>
                <c:set var="endPage" value="${maxPage}"></c:set>
            </c:when>
            <c:when test="${page<bz/2}">
                <c:set var="beginPage" value="1"></c:set>
                <c:set var="endPage" value="${bz}"></c:set>
            </c:when>
            <c:otherwise>
                <c:set var="beginPage" value="${page-bz/2+1}"></c:set>
                <c:set var="endPage" value="${page+bz/2}"></c:set>
            </c:otherwise>
        </c:choose>

        <c:forEach var="i" begin="${beginPage}" end="${endPage}" step="1">
            <li class="${page==i?'active':''}">
                <a href="${urlL }&page=${i }&pageSize=${pageSize}">${i }</a>
            </li>
        </c:forEach>
        <li class="${page>=maxPage?'disabled':'' }"><a href="${urlL }&page=${page+1 }&pageSize=${pageSize}">后一页</a></li>
        <li class="${page>=maxPage?'disabled':'' }"><a href="${urlL }&page=${maxPage }&pageSize=${pageSize}">&raquo;</a></li>
    </ul>
    </div>

</c:if>

<%@include file="inc/_toTop.jsp"%>
</body>
</html>
